import {io} from 'socket.io-client'
// location.origin+'/zero-admin'
const socket = io('http://192.168.17.34:8000');
// socket.connected //套接字当前是否连接到服务器。
// socket.disconnected //套接字当前是否与服务器断开连接。
// socket.id  套接字会话的唯一标识符
socket.on("connect", () => {
	console.log("已连接服务",socket.id); // x8WIv7-mJelg7on_ALbx
});

socket.on("connect_error", (error) => {
	if (socket.active) {
		// temporary failure, the socket will automatically try to reconnect
		console.log("connect_error:连接临时断开，即将重连",socket.id); // x8WIv7-mJelg7on_ALbx
	} else {
		// the connection was denied by the server
		// in that case, `socket.connect()` must be manually called in order to reconnect
		console.log('连接失败，需要手动重连',error.message);
	}
	
});

socket.on("disconnect", (reason, details) => {
	if (socket.active) {
		// temporary disconnection, the socket will automatically try to reconnect
		console.log("disconnect:连接临时断开，即将重连",socket.id); // x8WIv7-mJelg7on_ALbx
	} else {
		// the connection was forcefully closed by the server or the client itself
		// in that case, `socket.connect()` must be manually called in order to reconnect
		console.log("连接丢失，需要手动重连",socket.id,reason); // undefined
	}
});

socket.on("data", data => {
	console.log("收到数据：",data);
});

export default 1;